# -*- coding: utf-8 -*-

import mod.server.extraServerApi as svrApi
from myDemo import logger
import myDemo.cfg.sys as cSys

SvrSystem = svrApi.GetServerSystemCls()
nameSpc = svrApi.GetEngineNamespace()
sysName = svrApi.GetEngineSystemName()
compF = svrApi.GetEngineCompFactory()

class myDemoModSvr(SvrSystem):
    def __init__(self, namespace, systemName):
        SvrSystem.__init__(self, namespace, systemName)
        logger.critical("===== init %s =====" % cSys.SvrName)
        self.ListenEvt()

    def Destroy(self):
        self.UnEvt()

    def ListenEvt(self):
        self.ListenForEvent(nameSpc, sysName, "ServerChatEvent", self, self.OnChat)

    def UnEvt(self):
        self.UnListenForEvent(nameSpc, sysName, "ServerChatEvent", self, self.OnChat)

    def OnChat(self, args): 
        compF.CreateMsg(args['playerId']).NotifyOneMessage(args['playerId'], cSys.ChatFeBckMsg)
